<?php

/**
 * Ad form.
 *
 * @package    wills
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class AdForm extends BaseAdForm
{
  public function configure()
  {
	unset(
      $this['created_at'], 
      $this['updated_at'],
	  $this['thumb'],
	  $this['is_valid']
    );
		//广告图片
	$this->widgetSchema['image'] = new sfWidgetFormInputFile();
    $this->validatorSchema['image'] = new sfValidatorFile(array(
      'max_size' => 3 * 1024 * 1024,
      'path' => Wills::getUploadDirByWebPath(sfConfig::get('app_path_ad_image')),
      'mime_types' => 'web_images',
	  'required' => $this->isNew()
    ));

    $this->validatorSchema['image']->setMessage('required', '请上传广告图片');

    $this->validatorSchema['title']->setMessage('required', '请填写广告标题');
	
    $this->validatorSchema['adtype_id']->setMessage('required', '请选择广告类型');
	
    $this->validatorSchema['link']->setMessage('required', '请填写广告链接');
    $this->widgetSchema['image'] = new sfWidgetFormInputFileEditable(array(
      'is_image' => true,
      'edit_mode' => !$this->isNew(),
      'file_src' => sprintf(sfConfig::get('app_path_ad_image'),$this->getObject()->getImage()),
      'with_delete' => false
    ));
  }
}
